def setup():
    size(800,600)
    
def simple_finder(startp,endp):
    x1,y1 = startp
    current_pos = PVector(x1,y1)
    whole_path = [startp]
    x2,y2 = endp
    if (current_pos.x,current_pos.y) == endp:
        return whole_path
    else:
        while (current_pos.x,current_pos.y) != endp:
            dir = ''
            if current_pos.x!= endp[0]:
                if current_pos.x > endp[0]:
                    dir = 'left'
                else:
                    dir = 'right'
            elif current_pos.y!= endp[1]:
                if current_pos.y > endp[1]:
                    dir = 'up'
                else:
                    dir = 'down'
            dmap = {'left':(-1,0),'right':(1,0),'up':(0,-1),'down':(0,1)}
            dx,dy = dmap[dir]
            current_pos.add(PVector(dx,dy ))
            whole_path.append((current_pos.x,current_pos.y))
    return whole_path
        
    
def draw():
    background(255)
    
    for row in range(10):
        for col in range(10):
            stroke(0)
            fill(255)
            rect( col*40,row*40,40,40)
    sx,sy = (5,4)
    ex,ey = (2,2)
    path = simple_finder((5,4),(2,2))
    print(path)
    for x,y in path:
        fill(205, 193, 255)
        rect( x*40,y*40,40,40)
    fill(229, 217, 242)
    rect( sx*40,sy*40,40,40)
    fill(165, 148, 249)
    rect( ex*40,ey*40,40,40)
            